library(visage)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5     ✓ purrr   0.3.4
## ✓ tibble  3.1.6     ✓ dplyr   1.0.7
## ✓ tidyr   1.2.0     ✓ stringr 1.4.0
## ✓ readr   1.4.0     ✓ forcats 0.5.1
## Warning: package 'tidyr' was built under R version 4.1.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()

N: 50

Sigma: 0.125

mod <- simple_cubic_model(x = rand_uniform(-1, 1), sigma = 0.125)
ori_dat <- mod$gen(50)
i <- 0
plot_list <- list()

for (a in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
  for (b in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
    i <- i + 1
    mod$set_prm("a", a) %>%
      {.$set_prm("b", b)} %>%
      {.$gen(50, computed = select(ori_dat, x, e))} %>%
      {mod$plot(., remove_axis = TRUE, remove_grid_line = TRUE, theme = theme_light())} +
      ggtitle(glue::glue("a:{a}, b:{b}")) -> plot_list[[i]]
  }
} 

patchwork::wrap_plots(plot_list, ncol = 7)

Sigma: 0.25

mod <- simple_cubic_model(x = rand_uniform(-1, 1), sigma = 0.25)
ori_dat <- mod$gen(50)
i <- 0
plot_list <- list()

for (a in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
  for (b in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
    i <- i + 1
    mod$set_prm("a", a) %>%
      {.$set_prm("b", b)} %>%
      {.$gen(50, computed = select(ori_dat, x, e))} %>%
      {mod$plot(., remove_axis = TRUE, remove_grid_line = TRUE, theme = theme_light())} +
      ggtitle(glue::glue("a:{a}, b:{b}")) -> plot_list[[i]]
  }
} 

patchwork::wrap_plots(plot_list, ncol = 7)

Sigma: 0.5

mod <- simple_cubic_model(x = rand_uniform(-1, 1), sigma = 0.5)
ori_dat <- mod$gen(50)
i <- 0
plot_list <- list()

for (a in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
  for (b in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
    i <- i + 1
    mod$set_prm("a", a) %>%
      {.$set_prm("b", b)} %>%
      {.$gen(50, computed = select(ori_dat, x, e))} %>%
      {mod$plot(., remove_axis = TRUE, remove_grid_line = TRUE, theme = theme_light())} +
      ggtitle(glue::glue("a:{a}, b:{b}")) -> plot_list[[i]]
  }
} 

patchwork::wrap_plots(plot_list, ncol = 7)

Sigma: 1

mod <- simple_cubic_model(x = rand_uniform(-1, 1), sigma = 1)
ori_dat <- mod$gen(50)
i <- 0
plot_list <- list()

for (a in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
  for (b in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
    i <- i + 1
    mod$set_prm("a", a) %>%
      {.$set_prm("b", b)} %>%
      {.$gen(50, computed = select(ori_dat, x, e))} %>%
      {mod$plot(., remove_axis = TRUE, remove_grid_line = TRUE, theme = theme_light())} +
      ggtitle(glue::glue("a:{a}, b:{b}")) -> plot_list[[i]]
  }
} 

patchwork::wrap_plots(plot_list, ncol = 7)

N: 100

Sigma: 0.125

mod <- simple_cubic_model(x = rand_uniform(-1, 1), sigma = 0.125)
ori_dat <- mod$gen(100)
i <- 0
plot_list <- list()

for (a in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
  for (b in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
    i <- i + 1
    mod$set_prm("a", a) %>%
      {.$set_prm("b", b)} %>%
      {.$gen(100, computed = select(ori_dat, x, e))} %>%
      {mod$plot(., remove_axis = TRUE, remove_grid_line = TRUE, theme = theme_light())} +
      ggtitle(glue::glue("a:{a}, b:{b}")) -> plot_list[[i]]
  }
} 

patchwork::wrap_plots(plot_list, ncol = 7)

Sigma: 0.25

mod <- simple_cubic_model(x = rand_uniform(-1, 1), sigma = 0.25)
ori_dat <- mod$gen(100)
i <- 0
plot_list <- list()

for (a in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
  for (b in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
    i <- i + 1
    mod$set_prm("a", a) %>%
      {.$set_prm("b", b)} %>%
      {.$gen(100, computed = select(ori_dat, x, e))} %>%
      {mod$plot(., remove_axis = TRUE, remove_grid_line = TRUE, theme = theme_light())} +
      ggtitle(glue::glue("a:{a}, b:{b}")) -> plot_list[[i]]
  }
} 

patchwork::wrap_plots(plot_list, ncol = 7)

Sigma: 0.5

mod <- simple_cubic_model(x = rand_uniform(-1, 1), sigma = 0.5)
ori_dat <- mod$gen(100)
i <- 0
plot_list <- list()

for (a in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
  for (b in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
    i <- i + 1
    mod$set_prm("a", a) %>%
      {.$set_prm("b", b)} %>%
      {.$gen(100, computed = select(ori_dat, x, e))} %>%
      {mod$plot(., remove_axis = TRUE, remove_grid_line = TRUE, theme = theme_light())} +
      ggtitle(glue::glue("a:{a}, b:{b}")) -> plot_list[[i]]
  }
} 

patchwork::wrap_plots(plot_list, ncol = 7)

Sigma: 1

mod <- simple_cubic_model(x = rand_uniform(-1, 1), sigma = 1)
ori_dat <- mod$gen(100)
i <- 0
plot_list <- list()

for (a in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
  for (b in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
    i <- i + 1
    mod$set_prm("a", a) %>%
      {.$set_prm("b", b)} %>%
      {.$gen(100, computed = select(ori_dat, x, e))} %>%
      {mod$plot(., remove_axis = TRUE, remove_grid_line = TRUE, theme = theme_light())} +
      ggtitle(glue::glue("a:{a}, b:{b}")) -> plot_list[[i]]
  }
} 

patchwork::wrap_plots(plot_list, ncol = 7)

N: 300

Sigma: 0.125

mod <- simple_cubic_model(x = rand_uniform(-1, 1), sigma = 0.125)
ori_dat <- mod$gen(300)
i <- 0
plot_list <- list()

for (a in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
  for (b in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
    i <- i + 1
    mod$set_prm("a", a) %>%
      {.$set_prm("b", b)} %>%
      {.$gen(300, computed = select(ori_dat, x, e))} %>%
      {mod$plot(., remove_axis = TRUE, remove_grid_line = TRUE, theme = theme_light())} +
      ggtitle(glue::glue("a:{a}, b:{b}")) -> plot_list[[i]]
  }
} 

patchwork::wrap_plots(plot_list, ncol = 7)

Sigma: 0.25

mod <- simple_cubic_model(x = rand_uniform(-1, 1), sigma = 0.25)
ori_dat <- mod$gen(300)
i <- 0
plot_list <- list()

for (a in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
  for (b in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
    i <- i + 1
    mod$set_prm("a", a) %>%
      {.$set_prm("b", b)} %>%
      {.$gen(300, computed = select(ori_dat, x, e))} %>%
      {mod$plot(., remove_axis = TRUE, remove_grid_line = TRUE, theme = theme_light())} +
      ggtitle(glue::glue("a:{a}, b:{b}")) -> plot_list[[i]]
  }
} 

patchwork::wrap_plots(plot_list, ncol = 7)

Sigma: 0.5

mod <- simple_cubic_model(x = rand_uniform(-1, 1), sigma = 0.5)
ori_dat <- mod$gen(300)
i <- 0
plot_list <- list()

for (a in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
  for (b in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
    i <- i + 1
    mod$set_prm("a", a) %>%
      {.$set_prm("b", b)} %>%
      {.$gen(300, computed = select(ori_dat, x, e))} %>%
      {mod$plot(., remove_axis = TRUE, remove_grid_line = TRUE, theme = theme_light())} +
      ggtitle(glue::glue("a:{a}, b:{b}")) -> plot_list[[i]]
  }
} 

patchwork::wrap_plots(plot_list, ncol = 7)

Sigma: 1

mod <- simple_cubic_model(x = rand_uniform(-1, 1), sigma = 1)
ori_dat <- mod$gen(300)
i <- 0
plot_list <- list()

for (a in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
  for (b in c(-1.5, -0.75, -0.25, 0, 0.25, 0.75, 1.5)) {
    i <- i + 1
    mod$set_prm("a", a) %>%
      {.$set_prm("b", b)} %>%
      {.$gen(300, computed = select(ori_dat, x, e))} %>%
      {mod$plot(., remove_axis = TRUE, remove_grid_line = TRUE, theme = theme_light())} +
      ggtitle(glue::glue("a:{a}, b:{b}")) -> plot_list[[i]]
  }
} 

patchwork::wrap_plots(plot_list, ncol = 7)